# encoding:utf8


class Constant(object):
    REQUIRE_PACKINFO_FMT = "require_pack.json"    # 必须配置文件格式模板
    FULL_PACKINFO_FMT = "full_pack.json"          # 所有可配置项
    PACKINFO_FILE = "packcfg.json"                # 包配置文件名
    CONFIG_FILE = "ccpm_conf"  # 本地模块安装文件夹

    L_PACKINSTALL_DIR = "ccpm_plugins"  # 本地模块安装文件夹

    MODULE_CACHE_FILE = ".cache"
    VER_SEMANTIC = ["beta", "rc", "stable", "fix"]

    STATIC_ENV_PATH = "/usr/local/ccpm/static"  # static安装路径
    INSTALL_PATH = "/usr/local/ccpm"  # ccpm 安装路径
    HOOKS_PATH = "/usr/local/ccpm/static/hooks"  # hooks文件相对路径


class Ptype:
    UNKNOW = "unknow" or "" or None
    # 100x
    CODE_LUA = "lua"
    CODE_PYTHON = "python"
    # 200x
    CODE_GO = "go"
    # 500x
    CODE_XLWORK = "xlwork"

    PTYPE_NAMEID_MAP = {
        "unknow": 0,
        "lua": 1001,
        "python": 1002,
        "go": 2001,
        "xlwork": 5001,
    }

    @staticmethod
    def get_desc(ptype):
        for key in Ptype.PTYPE_NAMEID_MAP.keys():
            if Ptype.PTYPE_NAMEID_MAP[key] == ptype:
                return key

    @staticmethod
    def get_ptype(pdesc):
        if pdesc in Ptype.PTYPE_NAMEID_MAP:
            return Ptype.PTYPE_NAMEID_MAP.get(pdesc)
